<?
if (!defined('SMF'))
	die('Hacking attempt...');

global $smcFunc, $txt, $scripturl, $settings, $user_info;
global $dbtables;

// Verify user login, if CheckLogin() returns false return to the calling script/function
if (CheckLogin() == false)
	return;

//-------------------------------------------------------------------------------------------------

BigTitle($txt['bnt_dump_title']);
 
// Pull player info.
$result = $smcFunc['db_query']('', '
	SELECT *
	FROM {raw:db_ships}
	WHERE user_id = {int:user_id}
	LIMIT 1',
	array(
		'db_ships' => $dbtables['ships'],
		'user_id' => $user_info['id'],
	)
);
$playerinfo = $smcFunc['db_fetch_assoc']($result);
$smcFunc['db_free_result']($result);

// Figure out where the player is in the Universe.
$result = $smcFunc['db_query']('', '
	SELECT *
	FROM {raw:db_universe}
	WHERE sector_id = {int:sector_id}',
	array(
		'db_universe' => $dbtables['universe'],
		'sector_id' => $playerinfo['sector']
	)
);
$sectorinfo = $smcFunc['db_fetch_assoc']($result);
$smcFunc['db_free_result']($result);

if ($playerinfo['turns'] < 1)
{
	echo $txt['bnt_dump_turn'], '<br><br>';
	TextMainMenu();
	return;
}

if ($playerinfo['ship_colonists'] == 0)
	echo $txt['bnt_dump_nocol'], '<br><br>';
elseif ($sectorinfo['port_type'] == "special")
{
	$update = $smcFunc['db_query']('', '
		UPDATE {raw:db_ships}
		SET ship_colonists = 0,
			turns = turns - 1,
			turns_used = turns_used + 1
		WHERE ship_id = {int:ship_id}',
		array(
			'db_ships' => $dbtables['ships'],
			'ship_id' => $playerinfo['ship_id']
		)
	);
	echo $txt['bnt_dump_dumped'], '<br><br>';
}
else
	echo $txt['bnt_dump_nono'], '<br><br>';
	
TextMainMenu();
?>
